{% extends "base.html" %}

{% block content %}
<script>
  function goBack() {
    history.go(-1);
  }
</script>
<div class="jumbotron">
    <div class="container">
        <h1>道馆管理界面</h1>
        <br>
        <h2>{{ dojo.name }}</h2>
    </div>
</div>
<div class="container">
  <div id="dojo-delete-results" class="form-group">
    <div class="row text-center">
      <div class="col-lg-auto m-3">
        <figure>
          <a class="text-decoration-none" href="#" onclick="goBack()">
            <i class="fas fa-solid fa-arrow-left fa-3x"></i>
            <figcaption><b style="font-family: 'Courier New', Courier, monospace" id="tooltip">&nbsp;返回&nbsp;</b></figcaption>
          </a>
        </figure>
      </div>
        <div class="col-lg-auto m-3">
          <figure>
            <a class="text-decoration-none" href="{{ url_for('pwncollege_dojos.update_dojo', dojo=dojo.reference_id, update_code=dojo.update_code) }}" target="_blank">
              <i class="fas fa-upload fa-3x"></i>
              <figcaption><b style="font-family: 'Courier New', Courier, monospace">更新</b></figcaption>
            </a>
          </figure>
        </div>
        {% if is_admin() %}
        <div class="col-lg-auto m-3">
          <figure>
            <a id="dojo-delete-button" class="text-decoration-none delete-link" href="#" data-dojo="{{ dojo.reference_id }}">
              <i class="fas fa-trash fa-3x"></i>
              <figcaption><b style="font-family: 'Courier New', Courier, monospace">删除</b></figcaption>
            </a>
          </figure>
        </div>
        {% endif %}
        <div class="col-lg-auto m-3">
          <figure>
            <a id="dojo-invite-button" class="text-decoration-none" href="#" data-dojo="{{ url_for('pwncollege_dojos.join_dojo',dojo=dojo.reference_id,password=dojo.password)}}">
              <i class="fas fa-users fa-3x "></i>
              <figcaption><b style="font-family: 'Courier New', Courier, monospace">邀请</b></figcaption>
            </a>
          </figure>
        </div>

        <div class="col-lg-auto m-3">
          <figure>
            <a class="text-decoration-none" href="{{ url_for('pwncollege_dojos.view_dojo_solves', dojo=dojo.reference_id) }}">
              <i class="fas fa-file-csv fa-3x"></i>
              <figcaption><b style="font-family: 'Courier New', Courier, monospace">解决方案</b></figcaption>
            </a>
          </figure>
        </div>
        {% if dojo.course %}
          <div class="col-lg-auto m-3">
            <figure>
              <a class="text-decoration-none" href="{{ url_for('course.view_all_grades', dojo=dojo.reference_id) }}">
                <i class="fas fa-signal fa-3x"></i>
                <figcaption><b style="font-family: 'Courier New', Courier, monospace">Grades</b></figcaption>
              </a>
            </figure>
          </div>
        {% endif %}
    </div>
    <div>
      <form method="post" id="dojo-award-prune-form" autocomplete="off">
        <div class="form-group">
          <input class="btn btn-mini btn-primary" id="_submit" name="_submit" type="submit" value="删除遗留道馆徽章">
        </div>
        <div id="dojo-award-prune-results" class="form-group">
        </div>
      </form>
      {% if is_admin() %}
      <form method="post" id="dojo-promote-dojo-form" autocomplete="off">
        <div class="form-group">
          <input class="btn btn-mini btn-primary" id="_submit" name="_submit" type="submit" value="设置该道馆为官方道馆">
        </div>
        <div id="dojo-promote-dojo-results" class="form-group">
        </div>
      </form>
      {% endif %}
    </div>
    <b style="font-family: 'Courier New', Courier, monospace">参考 ID: </b><code>{{ dojo.reference_id }}</code>
    <br>
    <b style="font-family: 'Courier New', Courier, monospace">道馆 ID: </b><code>{{ dojo.hex_dojo_id }}</code>
    <br>
    <!-- <b style="font-family: 'Courier New', Courier, monospace">Update Code: </b><code>{{ dojo.update_code }}</code>
    <br> -->
    <b style="font-family: 'Courier New', Courier, monospace">Git 哈希值: </b><code>{{ dojo.hash[:8] }}</code>
    <br>
    <b style="font-family: 'Courier New', Courier, monospace">管理员</b>
    <ul>
        {% for admin in dojo.admins %}
            <li>{{ admin.user.name }}</li>
        {% endfor %}
    </ul>
    <b style="font-family: 'Courier New', Courier, monospace">成员</b>
    <form method="post" id="dojo-promote-admin-form" autocomplete="off">
      <div class="form-group">
        {% for member in dojo.members %}
        <input type="radio" id="{{ member.user.id }}" name="user_id" value="{{ member.user.id }}">
        <label for="{{ member.user.id }}"><a href="{{ url_for('pwncollege_users.view_other', user_id=member.user.id) }}"><span id="name-for-{{member.user.id}}">{{ member.user.name }}</span></a></label>
        <br>
        {% endfor %}
        <input class="btn btn-mini btn-primary" id="_submit" name="_submit" type="submit" value="晋升为管理员">
      </div>
      <div id="dojo-promote-admin-results" class="form-group">
      </div>
    </form>
</div>
{% endblock %}

{% block entrypoint %}
    <script defer src="{{ url_for('views.themes', path='js/pages/settings.js') }}"></script>

{% endblock %}

{% block scripts %}
<script defer src="{{ url_for('views.themes', path='js/dojo/settings.js') }}"></script>
{% endblock %}
